/* --------------------------------------------------------
 * Copyright (c) Express Scripts, Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.common;

import java.util.Map;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

/**
 * The Enum IsNullEnum.
 */
public enum IsNullEnum {

    NULL {

        /*
         * (non-Javadoc)
         * 
         * @see com.esi.bfp.common.BfpClaimStatus#getCriterion(java.lang.String)
         */
        @Override
        public Criterion getCriterion(String fieldName) {
            return Restrictions.isNull(fieldName);
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * com.esi.bfp.common.BfpClaimStatus#getConditionString(java.util.Map,
         * java.lang.String)
         */
        @Override
        public String getConditionString(Map<String, Object> params, String fieldName) {
            return " and " + fieldName + " is null";
        }

    },
    NONULL {

        /*
         * (non-Javadoc)
         * 
         * @see com.esi.bfp.common.BfpClaimStatus#getCriterion(java.lang.String)
         */
        @Override
        public Criterion getCriterion(String fieldName) {
            return Restrictions.isNotNull(fieldName);
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * com.esi.bfp.common.BfpClaimStatus#getConditionString(java.util.Map,
         * java.lang.String)
         */
        @Override
        public String getConditionString(Map<String, Object> params, String fieldName) {
            return " and " + fieldName + " is not null";
        }

    };

    /**
     * Gets the clinical check enum by.
     * 
     * @param strNoNull the str no null
     * @return the clinical check enum by
     */
    public static IsNullEnum getClinicalCheckEnumBy(String strNoNull) {
        if (IsNullEnum.NONULL.name().equals(strNoNull)) {
            return NONULL;
        } else {
            return NULL;
        }
    }

    /**
     * Gets the criterion.
     * 
     * @param fieldName the field name
     * @return the criterion
     */
    public abstract Criterion getCriterion(String fieldName);

    /**
     * Gets the condition string.
     * 
     * @param params the params
     * @param fieldName the field name
     * @return the condition string
     */
    public abstract String getConditionString(Map<String, Object> params, String fieldName);

}
